<?php

$_POST['ctt_EventTime'] = '0000-00-00';
$_POST['ctt_City'] = 0;
if (strlen($_POST['ctt_Phone1']) > 5 || strlen($_POST['ctt_Mobile']) > 5) {
    if ($GLOBALS['MYT']->db_query("INSERT INTO clientes_ctt (cct_Client, cct_RegUser, cct_Phone1, cct_Mobile, cct_Email, cct_Name, cct_City, cct_Local, cct_EventTime, cct_Domain, cct_Observations)
		VALUES (0,
			{$_SESSION[$SESSID]},
			\"{$_POST['ctt_Phone1']}\",
			\"{$_POST['ctt_Mobile']}\",
			\"{$_POST['ctt_Email']}\",
			\"{$_POST['ctt_Name']}\",
			{$_POST['ctt_City']},
			\"{$_POST['ctt_Local']}\",
			\"{$_POST['ctt_EventTime']}\",
			{$_SESSION[$SESSCD]},
			\"{$_POST['ctt_Obs']}\")") == true) {

        if (isset($_POST['ctg_Chose']) && $_POST['ctg_Chose'] > 0) {

            $GLOBALS['MYT']->db_query("UPDATE campaigns_attrib SET cpg_Current = cpg_Current-1 WHERE cpg_ID = {$_POST['ctg_Chose']}");
            $GLOBALS['MYT']->db_query("INSERT INTO campaign_entries (cpn_Atrr, cpn_Client, cpn_Campaign, cpn_Origen, cpn_User, cpn_Time) VALUES ({$_POST['ctg_Chose']},0,4,{$_SESSION[$SESSCD]},{$_SESSION[$SESSID]},'{$sysTime}')");
        }
        echo '<div class="Confirm">Guardado.</div>';
    }
} else {

    echo '<div class="Error">Tem de inserir um telefone valido</div>';
}